
#include "BfcpMessageIf.hxx"
#include "rutil/DataStream.hxx"
#include "rutil/ResipAssert.h"

using namespace resip;

namespace bfcp
{
    BfcpMessageIf::Brief
        BfcpMessageIf::brief() const
    {
        return BfcpMessageIf::Brief(*this);
    }

    BfcpMessageIf::Brief::Brief(const BfcpMessageIf& source) :
        mSource(source)
    {
    }
}

std::ostream&
bfcp::operator<<(std::ostream& strm,
    const bfcp::BfcpMessageIf& msg)
{
    Data encoded;

    DataStream encodeStream(encoded);
    msg.encode(encodeStream);
    encodeStream.flush();

    strm << encoded.c_str();

    return strm;
}

std::ostream&
bfcp::operator<<(std::ostream& strm,
    const bfcp::BfcpMessageIf::Brief& brief)
{
    Data encoded;

    DataStream encodeStream(encoded);
    brief.mSource.encodeBrief(encodeStream);
    encodeStream.flush();

    strm << encoded.c_str();

    return strm;
}

#ifndef  RESIP_USE_STL_STREAMS
EncodeStream&
bfcp::operator<<(EncodeStream& strm,
    const bfcp::BfcpMessageIf& msg)
{
    return msg.encode(strm);
}

EncodeStream&
bfcp::operator<<(EncodeStream& strm,
    const bfcp::BfcpMessageIf::Brief& brief)
{
    return brief.mSource.encodeBrief(strm);
}
#endif
